package com.yuchen.bearrecord.controller;

import com.yuchen.bearrecord.config.Result;
import com.yuchen.bearrecord.entity.Prescription;
import com.yuchen.bearrecord.service.impl.PrescriptionServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/prescription")
public class PrescriptionController {
    @Resource
    private PrescriptionServiceImpl prescriptionService;

    @GetMapping("/getPrescriptions")
    @ResponseBody
    public Result getPrescriptions(){
        return prescriptionService.getPrescriptions();
    }

    @DeleteMapping("/deletePrescription")
    @ResponseBody
    public Result deletePrescription(@RequestParam("pid") Long pid) {
        return prescriptionService.deletePrescription(pid);
    }

    @PostMapping("/addPrescription")
    @ResponseBody
    public Result addPrescription(@RequestBody Prescription prescription) {
        return prescriptionService.addPrescription(prescription);
    }

    @PutMapping("/updateRecent")
    @ResponseBody
    public Result updateRecent(@RequestBody Prescription prescription) {
        return prescriptionService.updateRecent(prescription);
    }
}
